package com.linkai.刷题.weilai;

import java.util.Scanner;

/**
 * @Description: 同样采用暴力
 * @Author: 林凯
 * @Date: 2021/11/28 20:06
 */
public class T03 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] firstLint = sc.nextLine().split(" ");
        int n = Integer.valueOf(firstLint[0]);
        int m = Integer.valueOf(firstLint[1]);
        long max = -1;
        long [][] array = new long[n][m];
        for (int i = 0; i < n; i++) {
            String[] line = sc.nextLine().split(" ");
            for (int j = 0; j < m; j++) {
                array[i][j] = Long.valueOf(line[j]);
            }
        }

        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                // 上层for循环是比遍历矩阵中所有的元素
                // 下面对该元素，计算 x[i,j]
                long tempNumber = 1;
                // 先处理行
                for (int ii = 0; ii < n; ii++) {
                    if (ii == i) {
                        continue;
                    }
                    tempNumber = tempNumber * array[ii][j];
                }
                // 再处理列
                for (int jj = 0; jj < m; jj++) {
                    if (jj == j) {
                        continue;
                    }
                    tempNumber = tempNumber * array[i][jj];
                }
                if (tempNumber > max) {
                    max = tempNumber;
                }
            }
        }

        System.out.println(max);
    }
}
